var MagicString = require('magic-string');
var magicString = new MagicString('export var name = "ahhh"');

//返回magicString的克隆，删除原始字符串开头和结尾字符之前的所有内容
//类似于截取字符串
console.log(magicString.snip(0, 6).toString()); //export




//从开始到结束删除字符(索引永远是基于原始的字符串,而非改变后的)
console.log(magicString.remove(0,7).toString()); //var name = "ahhh"




//使用MagicString.Bundle可以联合多个源代码
//使用场景是 很多模块需要打包到一个文件里
let bundleString = new MagicString.Bundle();
bundleString.addSource({
  content: 'var a = 1;',
  separator: '\n'
})
bundleString.addSource({
  content: 'var b = 2;',
  separator: '\n'
})
console.log(bundleString.toString());
/*
var a = 1;
var b = 2;
*/
